import axios from 'axios'

const students = {
    // 获取学生数据
    getStudents(pageSize, currentPage) {
        return axios({
            url: "/students/getStudents",
            method: 'GET',
            params: {
                pageSize: pageSize,
                currentPage: currentPage
            }
        })
    },
    // 新增学生数据
    addStudents(name, age, sex, classesId, subjectsId, image) {
        return axios({
            url: "/students/addStudents",
            method: 'POST',
            data: {
                name: name,
                age: age,
                gender: sex,
                classesId: classesId,
                subjectsId: subjectsId,
                image: image
                    // image: image
            }
        })
    },
    //搜索学生
    searchStudents(choose, input, pageSize, currentPage) {
        return axios({
            url: "/students/getStudents",
            method: 'GET',
            params: {
                type: choose,
                value: input,
                pageSize: pageSize,
                currentPage: currentPage
            }
        })
    },
    //修改学生
    updateStudent(id, name, age, gender, classesId, subjectsId) {
        return axios({
            url: "/students/updateStudents",
            method: 'PUT',
            data: {
                _id: id,
                name: name,
                age: age,
                gender: gender,
                classesId: classesId,
                subjectsId: subjectsId
            }
        })
    },
    //获取要修改的学生
    getupdateStudent(id) {
        return axios({
            url: "/students/getStudentsById",
            method: 'GET',
            params: {
                _id: id,
            }
        })
    },
    //删除学生
    delStudent(id, name, age, sex) {
        return axios({
            url: "/students/deleteStudents",
            method: 'DELETE',
            data: {
                _id: id,
                name: name,
                age: age,
                gender: sex,
            }
        })
    },
}
export default students;